/**
 * Light-commons Project
 * http://light-commons.googlecode.com
 * Copyright (C) 2008 Jason Green
 * email: guileen@gmail.com
 *
 * License: Apache License 2.0 
 * (http://www.apache.org/licenses/LICENSE-2.0)
 *
 */
package org.lightmtv.response;

import javax.servlet.http.HttpServletResponse;

/**
 * @author gl
 * @since Jun 24, 2008
 */
public class TextResponse extends AbstractContentResponse{
	
	private CharSequence text;
	
	/**
	 * 
	 */
	public TextResponse() {
	}
	
	public TextResponse(CharSequence text){
		this.text = text;
	}
	
	/**
	 * @param encoding
	 * @param text
	 */
	public TextResponse(CharSequence text,String encoding) {
		super();
		setEncoding(encoding);
		this.text = text;
	}
	
	public TextResponse(CharSequence text,String encoding,String contentType){
		this(text,encoding);
		setContentType(contentType);
	}
	
	/**
	 * @return the text
	 */
	public CharSequence getText() {
		return text;
	}

	/**
	 * @param text the text to set
	 */
	public void setText(CharSequence text) {
		this.text = text;
	}

	@Override
	protected void sendQuietly(HttpServletResponse response) throws Exception {
		CharSequence text = getText();
		response.getWriter().write(text == null ? "" : text.toString());
	}
	
	
}
